#ifndef _MESHPOINTS_H
#define _MESHPOINTS_H

#include <vector>
#include <cmath>
#include <string>
#include <glm/glm.hpp>

#include <app/ameTypes.h>
#include <render/output/material.h>

struct Vertex {
public:
    
    Vertex ( glm::vec3 position, glm::vec2 textureCoordinates, glm::vec3 normal );
    
    glm::vec3* getPosition ();
    glm::vec2* getTextureCoordinates ();
    glm::vec3* getNormal ();
    
private:
    
    glm::vec3 position;
    glm::vec2 textureCoordinates;
    glm::vec3 normal;
};

struct Model {
    std::vector <glm::vec3> positions;
    std::vector <glm::vec2> textureCoordinates;
    std::vector <glm::vec3> normals;
    std::vector <unsigned int> indices;
    
    void calculateNormals ();
};

class Mesh {
public:
    
    Mesh ( Vertex* vertices, unsigned int verticesCount, unsigned int* indices, unsigned int indicesCount );
    Mesh ( std::string filename );
    
    void Draw ();
    
    ~Mesh ();
    
private:
    
    void InitMesh ( const Model& model );
    
    static const unsigned int BUFFERS_COUNT = 4;
    unsigned int m_vertexArrayObject;
	unsigned int m_vertexArrayBuffers [ BUFFERS_COUNT ];
	unsigned int m_numIndices;
};

#endif // _MESHPOINTS_H
